$(function () {
    var url = '/person/login';

    $('#submit').click(function () {
        var formData = new FormData();
        formData.append('username',$('#account').val());
        formData.append('password',$('#password').val());
        $.ajax({
            url:url,
            type:"POST",
            data:formData,
            contentType:false,
            processData:false,
            cache:false,
            success:function (data) {
                if (data.success) {
                    $.toast("登录成功!!!");
                    //将生成的token存放在localStorage中
                    localStorage.setItem('token',data.message);
                    location.href = "/index"
                }else {
                    $.toast(data.message);
                }
            }
        });
    });


    $('#tourist').click(function () {
        localStorage.removeItem('token');
        window.location.href = "/index";
    })

});
